package sagroup.dracots.tuple.metrics;

import sagroup.dracots.metrics.*;
import sagroup.dracots.metrics.util.*;

public class TupleMetrics implements Updater{

	private MetricsRecord metricsRecord;

	public MetricsTimeVaryingInt rd = 
		new MetricsTimeVaryingInt("rd");
	public MetricsTimeVaryingInt rdp = 
		new MetricsTimeVaryingInt("rdp");
	public MetricsTimeVaryingInt rdg = 
		new MetricsTimeVaryingInt("rdg");
	public MetricsTimeVaryingInt in = 
		new MetricsTimeVaryingInt("in");
	public MetricsTimeVaryingInt inp = 
		new MetricsTimeVaryingInt("inp");
	public MetricsTimeVaryingInt ing = 
		new MetricsTimeVaryingInt("ing");
	public MetricsTimeVaryingInt update = 
		new MetricsTimeVaryingInt("update");

	public MetricsTimeVaryingRate rdop = 
		new MetricsTimeVaryingRate("rdop");
	public MetricsTimeVaryingRate rdpop = 
		new MetricsTimeVaryingRate("rdpop");
	public MetricsTimeVaryingRate rdgop = 
		new MetricsTimeVaryingRate("rdgop");
	public MetricsTimeVaryingRate inop = 
		new MetricsTimeVaryingRate("inop");
	public MetricsTimeVaryingRate inpop = 
		new MetricsTimeVaryingRate("inpop");
	public MetricsTimeVaryingRate ingop = 
		new MetricsTimeVaryingRate("ingop");
	public MetricsTimeVaryingRate updateop = 
		new MetricsTimeVaryingRate("updateop");

	public TupleMetrics()
	{
		MetricsContext context = MetricsUtil.getContext("Lime");
		metricsRecord = MetricsUtil.createRecord(context, "Tuplespace");
		context.registerUpdater(this);
	}
	public  void doUpdate(MetricsContext unused)
	{
		synchronized (this)
		{
			rd.pushMetric(metricsRecord);
			rdp.pushMetric(metricsRecord);
			rdg.pushMetric(metricsRecord);
			in.pushMetric(metricsRecord);
			inp.pushMetric(metricsRecord);
			ing.pushMetric(metricsRecord);
			update.pushMetric(metricsRecord);

		}
		metricsRecord.update();
	}
	public void resetAllMinMax() {
		rdop.resetMinMax();
		rdpop.resetMinMax();
		rdgop.resetMinMax();
		inop.resetMinMax();
		inpop.resetMinMax();
		ingop.resetMinMax();
		updateop.resetMinMax();
	}


}
